﻿using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
using System.IO;
using System.Security.Authentication;

namespace AMS.Core
{
    // provide consistent error handling where possible
    public static class ExceptionHandler
    {
        #region Exception
        public static string DefaultExceptionMessage = "an unknown exception occurred";

        public static void Exception()
        {
            Exception(DefaultExceptionMessage, null);
        }

        public static void Exception(string message)
        {
            Exception(message, null);
        }

        public static void Exception(Exception innerException)
        {
            Exception(DefaultExceptionMessage, innerException);
        }

        public static void Exception(string message, Exception innerException)
        {
            throw new Exception(message, innerException);
        } 
        #endregion

        public static string DefaultFileNotFoundExceptionMessage = "Error: specified file could not be found."; 

        public static void FileNotFoundException()
        {
            throw new FileNotFoundException(DefaultFileNotFoundExceptionMessage);
        }

        public static string DefaultArgumentNullExceptionMessage = "Error: null parameter not permitted.";

        public static void ArgumentNullException()
        {
            throw new ArgumentNullException(DefaultFileNotFoundExceptionMessage);
        }
        
        public static string DefaultDirectoryNotFoundExceptionMessage = "Error: specified directory could not be found.";
        
        public static void DirectoryNotFoundException()
        {
            throw new DirectoryNotFoundException(DefaultDirectoryNotFoundExceptionMessage);
        }
        
        public static string DefaultNotExecutedExceptionMessage = "can't undo a Command that hasn't been executed";
        
        public static void NotExecutedException()
        {
            throw new Exception(DefaultNotExecutedExceptionMessage);
        }
        
        public static string DefaultAlreadyExecutedExceptionMessage = "already executed";
        
        public static void AlreadyExecutedException()
        {
            throw new Exception(DefaultAlreadyExecutedExceptionMessage);
        }
        
        public static string DefaultInvalidFilenameExceptionMessage = "invalid filename";
        
        public static void InvalidFilenameException()
        {
            throw new Exception(DefaultInvalidFilenameExceptionMessage);
        }
        
        public static void NotImplementedException()
        {
            throw new NotImplementedException();
        }

        public static string DefaultNoNextExceptionMessage = "iterator does not have next";
        
        internal static void NoNextException()
        {
            throw new ArgumentOutOfRangeException(DefaultNoNextExceptionMessage);
        }

        public static string DefaultInvalidCredentialsExceptionMessage = "invalid credentials";

        public static void InvalidCredentialsException()
        {
            throw new AuthenticationException(DefaultInvalidCredentialsExceptionMessage);
        }
    }
}
